Skip to content

Hold module-level skips and missing modules in the Spec test gate - #205

Merged
guijacquemet merged 3 commits into
mainfrom
claude/spec-gate-skips
Nov 7, 2026
Merged

guijacquemet merged 3 commits into
mainfrom
claude/spec-gate-skips

Conversation

@guijacquemet

@guijacquemet guijacquemet commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #203

What and why

tests/spec_gate.py only turned skips of already-collected items into failures. Now:

  • Module-level skips: a pytest_collectreport hook (tryfirst, so pytest's own bookkeeping sees the change) turns the skipped collect report of a test_spec_*.py module (pytest.skip(..., allow_module_level=True) or a module-level importorskip) into a failed collection.
  • Missing modules: items collected per Spec module are counted (pytest_itemcollected, before any -k), and pytest_collection_finish refuses (usage error, non-zero exit) a run over the whole tests folder that collected no item from a module of EXPECTED_MODULES (the 14 current modules). Runs of chosen files, test ids or another folder check only what they select, so they do not fail for modules they did not ask for. The list asks for at least one item per module, not exact counts, because parametrized counts follow the vendored fixtures; test_every_spec_module_of_the_repository_is_listed keeps the list equal to the files on disk.
  • spec_gate_plugin.py reads SPEC_GATE_EXPECTED for the gate's own tests; docs/development.md and CHANGELOG updated.

Regression tests (tests/test_spec_gate.py)

Old gate code (tests run with the old spec_gate.py, conftest.py and plugin): 5 FAILED, 4 passed.

  • test_a_module_level_skip_in_a_spec_module_fails_the_run: fails on old, passes now.
  • test_a_module_level_importorskip_in_a_spec_module_fails_the_run: fails on old, passes now.
  • test_a_missing_spec_module_fails_a_whole_folder_run: fails on old, passes now.
  • test_a_spec_module_without_a_collected_test_fails_a_whole_folder_run and test_every_spec_module_of_the_repository_is_listed: fail on old, pass now.
  • Controls that pass on both: a module-level skip in a non-Spec module may still skip; a run of one chosen file does not need the other modules.

Also checked by hand on the real tree: moving tests/test_spec_rules_table.py away makes pytest tests stop with "no test was collected from the Spec conformance module(s)"; restored, 4049 tests collect.

Checks

python tools/check.py (ruff check, ruff format --check, pytest, code rules): 4045 passed, 4 skipped, 0 failed, 2 warnings. The 4 skips are existing platform skips (case-insensitive file system, file-mode permissions as root), not Spec tests. CHANGELOG entry added; expect conflicts with other open PRs, keep both entries.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Scma6W3LC11s3qjXHZuGDm

A test_spec_*.py module skipped while it is collected (module-level
skip or importorskip) is now a failed collection, and a run over the
whole tests folder fails when no test was collected from a module of
EXPECTED_MODULES (a deleted or emptied Spec module).

Fixes #203

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Scma6W3LC11s3qjXHZuGDm
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Scma6W3LC11s3qjXHZuGDm

# Conflicts:
#	CHANGELOG.md
#196 added the module on main; the gate refuses an unlisted Spec module, as designed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Scma6W3LC11s3qjXHZuGDm
@guijacquemet
guijacquemet merged commit aa94a52 into main Nov 7, 2026
7 checks passed
@guijacquemet
guijacquemet deleted the claude/spec-gate-skips branch November 7, 2026 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spec test gate misses module-level skips and missing test_spec modules

2 participants